// Copyright Citra Emulator Project / Azahar Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#include "common/archives.h"
#include "core/hle/service/am/am_net.h"

namespace Service::AM {

AM_NET::AM_NET(std::shared_ptr<Module> am) : Module::Interface(std::move(am), "am:net", 5) {
    static const FunctionInfo functions[] = {
        // clang-format off
        {0x0001, &AM_NET::GetNumPrograms, "GetNumPrograms"},
        {0x0002, &AM_NET::GetProgramList, "GetProgramList"},
        {0x0003, &AM_NET::GetProgramInfos, "GetProgramInfos"},
        {0x0004, &AM_NET::DeleteUserProgram, "DeleteUserProgram"},
        {0x0005, &AM_NET::GetProductCode, "GetProductCode"},
        {0x0006, nullptr, "GetStorageId"},
        {0x0007, &AM_NET::DeleteTicket, "DeleteTicket"},
        {0x0008, &AM_NET::GetNumTickets, "GetNumTickets"},
        {0x0009, &AM_NET::GetTicketList, "GetTicketList"},
        {0x000A, &AM_NET::GetDeviceID, "GetDeviceID"},
        {0x000B, &AM_NET::GetNumImportTitleContexts, "GetNumImportTitleContexts"},
        {0x000C, &AM_NET::GetImportTitleContextList, "GetImportTitleContextList"},
        {0x000D, &AM_NET::GetImportTitleContexts, "GetImportTitleContexts"},
        {0x000E, &AM_NET::DeleteImportTitleContext, "DeleteImportTitleContext"},
        {0x000F, &AM_NET::GetNumImportContentContexts, "GetNumImportContentContexts"},
        {0x0010, &AM_NET::GetImportContentContextList, "GetImportContentContextList"},
        {0x0011, &AM_NET::GetImportContentContexts, "GetImportContentContexts"},
        {0x0012, nullptr, "DeleteImportContentContexts"},
        {0x0013, &AM_NET::NeedsCleanup, "NeedsCleanup"},
        {0x0014, &AM_NET::DoCleanup, "DoCleanup"},
        {0x0015, nullptr, "DeleteAllImportContexts"},
        {0x0016, nullptr, "DeleteAllTemporaryPrograms"},
        {0x0017, nullptr, "ImportTwlBackupLegacy"},
        {0x0018, nullptr, "InitializeTitleDatabase"},
        {0x0019, &AM_NET::QueryAvailableTitleDatabase, "QueryAvailableTitleDatabase"},
        {0x001A, nullptr, "CalcTwlBackupSize"},
        {0x001B, nullptr, "ExportTwlBackup"},
        {0x001C, nullptr, "ImportTwlBackup"},
        {0x001D, nullptr, "DeleteAllTwlUserPrograms"},
        {0x001E, nullptr, "ReadTwlBackupInfo"},
        {0x001F, nullptr, "DeleteAllExpiredUserPrograms"},
        {0x0020, nullptr, "GetTwlArchiveResourceInfo"},
        {0x0021, &AM_NET::GetPersonalizedTicketInfoList, "GetPersonalizedTicketInfoList"},
        {0x0022, nullptr, "DeleteAllImportContextsFiltered"},
        {0x0023, &AM_NET::GetNumImportTitleContextsFiltered, "GetNumImportTitleContextsFiltered"},
        {0x0024, &AM_NET::GetImportTitleContextListFiltered, "GetImportTitleContextListFiltered"},
        {0x0025, &AM_NET::CheckContentRights, "CheckContentRights"},
        {0x0026, nullptr, "GetTicketLimitInfos"},
        {0x0027, nullptr, "GetDemoLaunchInfos"},
        {0x0028, nullptr, "ReadTwlBackupInfoEx"},
        {0x0029, nullptr, "DeleteUserProgramsAtomically"},
        {0x002A, nullptr, "GetNumExistingContentInfosSystem"},
        {0x002B, nullptr, "ListExistingContentInfosSystem"},
        {0x002C, &AM_NET::GetProgramInfosIgnorePlatform, "GetProgramInfosIgnorePlatform"},
        {0x002D, &AM_NET::CheckContentRightsIgnorePlatform, "CheckContentRightsIgnorePlatform"},
        {0x0401, nullptr, "UpdateFirmwareTo"},
        {0x0402, &AM_NET::BeginImportProgram, "BeginImportProgram"},
        {0x0403, &AM_NET::BeginImportProgramTemporarily, "BeginImportProgramTemporarily"},
        {0x0404, nullptr, "CancelImportProgram"},
        {0x0405, &AM_NET::EndImportProgram, "EndImportProgram"},
        {0x0406, &AM_NET::EndImportProgramWithoutCommit, "EndImportProgramWithoutCommit"},
        {0x0407, &AM_NET::CommitImportPrograms, "CommitImportPrograms"},
        {0x0408, &AM_NET::GetProgramInfoFromCia, "GetProgramInfoFromCia"},
        {0x0409, &AM_NET::GetSystemMenuDataFromCia, "GetSystemMenuDataFromCia"},
        {0x040A, &AM_NET::GetDependencyListFromCia, "GetDependencyListFromCia"},
        {0x040B, &AM_NET::GetTransferSizeFromCia, "GetTransferSizeFromCia"},
        {0x040C, &AM_NET::GetCoreVersionFromCia, "GetCoreVersionFromCia"},
        {0x040D, &AM_NET::GetRequiredSizeFromCia, "GetRequiredSizeFromCia"},
        {0x040E, &AM_NET::CommitImportProgramsAndUpdateFirmwareAuto, "CommitImportProgramsAndUpdateFirmwareAuto"},
        {0x040F, nullptr, "UpdateFirmwareAuto"},
        {0x0410, &AM_NET::DeleteProgram, "DeleteProgram"},
        {0x0411, nullptr, "GetTwlProgramListForReboot"},
        {0x0412, &AM_NET::GetSystemUpdaterMutex, "GetSystemUpdaterMutex"},
        {0x0413, &AM_NET::GetMetaSizeFromCia, "GetMetaSizeFromCia"},
        {0x0414, &AM_NET::GetMetaDataFromCia, "GetMetaDataFromCia"},
        {0x0415, nullptr, "CheckDemoLaunchRights"},
        {0x0416, nullptr, "GetInternalTitleLocationInfo"},
        {0x0417, nullptr, "PerpetuateAgbSaveData"},
        {0x0418, nullptr, "BeginImportProgramForOverWrite"},
        {0x0419, nullptr, "BeginImportSystemProgram"},
        {0x0801, &AM_NET::BeginImportTicket, "BeginImportTicket"},
        {0x0802, nullptr, "CancelImportTicket"},
        {0x0803, &AM_NET::EndImportTicket, "EndImportTicket"},
        {0x0804, &AM_NET::BeginImportTitle, "BeginImportTitle"},
        {0x0805, &AM_NET::StopImportTitle, "StopImportTitle"},
        {0x0806, &AM_NET::ResumeImportTitle, "ResumeImportTitle"},
        {0x0807, &AM_NET::CancelImportTitle, "CancelImportTitle"},
        {0x0808, &AM_NET::EndImportTitle, "EndImportTitle"},
        {0x0809, &AM_NET::CommitImportTitles, "CommitImportTitles"},
        {0x080A, &AM_NET::BeginImportTmd, "BeginImportTmd"},
        {0x080B, nullptr, "CancelImportTmd"},
        {0x080C, &AM_NET::EndImportTmd, "EndImportTmd"},
        {0x080D, &AM_NET::CreateImportContentContexts, "CreateImportContentContexts"},
        {0x080E, &AM_NET::BeginImportContent, "BeginImportContent"},
        {0x080F, &AM_NET::StopImportContent, "StopImportContent"},
        {0x0810, &AM_NET::ResumeImportContent, "ResumeImportContent"},
        {0x0811, &AM_NET::CancelImportContent, "CancelImportContent"},
        {0x0812, &AM_NET::EndImportContent, "EndImportContent"},
        {0x0813, &AM_NET::GetNumCurrentImportContentContexts, "GetNumCurrentImportContentContexts"},
        {0x0814, &AM_NET::GetCurrentImportContentContextList, "GetCurrentImportContentContextList"},
        {0x0815, &AM_NET::GetCurrentImportContentContexts, "GetCurrentImportContentContexts"},
        {0x0816, &AM_NET::Sign, "Sign"},
        {0x0817, nullptr, "Verify"},
        {0x0818, &AM_NET::GetDeviceCert, "GetDeviceCert"},
        {0x0819, nullptr, "ImportCertificates"},
        {0x081A, nullptr, "ImportCertificate"},
        {0x081B, &AM_NET::CommitImportTitlesAndUpdateFirmwareAuto, "CommitImportTitlesAndUpdateFirmwareAuto"},
        {0x081C, &AM_NET::DeleteTicketId, "DeleteTicketId"},
        {0x081D, &AM_NET::GetNumTicketIds, "GetNumTicketIds"},
        {0x081E, &AM_NET::GetTicketIdList, "GetTicketIdList"},
        {0x081F, &AM_NET::GetNumTicketsOfProgram, "GetNumTicketsOfProgram"},
        {0x0820, &AM_NET::ListTicketInfos, "ListTicketInfos"},
        {0x0821, nullptr, "GetRightsOnlyTicketData"},
        {0x0822, &AM_NET::GetNumCurrentContentInfos, "GetNumCurrentContentInfos"},
        {0x0823, &AM_NET::FindCurrentContentInfos, "FindCurrentContentInfos"},
        {0x0824, &AM_NET::ListCurrentContentInfos, "ListCurrentContentInfos"},
        {0x0825, &AM_NET::CalculateContextRequiredSize, "CalculateContextRequiredSize"},
        {0x0826, &AM_NET::UpdateImportContentContexts, "UpdateImportContentContexts"},
        {0x0827, nullptr, "DeleteAllDemoLaunchInfos"},
        {0x0828, nullptr, "BeginImportTitleForOverWrite"},
        {0x0829, &AM_NET::ExportTicketWrapped, "ExportTicketWrapped"},
        // clang-format on
    };
    RegisterHandlers(functions);
}

} // namespace Service::AM

SERIALIZE_EXPORT_IMPL(Service::AM::AM_NET)
